package otherOrganizations;

import java.util.LinkedList;

import enviornment.Clock;
import agentsSME.SME;
import agentsSME.Stock;
import repast.simphony.engine.schedule.ScheduledMethod;
import repast.simphony.essentials.RepastEssentials;

public class Supplier {
	private double time;
	private String ID;
	private double amount;
	private int frequency;
	private int priority;
	private LinkedList<SME> customers;
	private Clock clock;
	public Supplier(String id, double amount, int f, int priority ) {
		time=0.0;
		clock=new Clock();
		this.setID(id);
		this.setAmountSupply(amount);
		this.setFrequency(f);
		this.setPriority(priority);
		customers=new LinkedList<SME>();
	}
	public void addCustomers(SME sme){
		customers.add(sme);
	}
	@ScheduledMethod(start = 121, interval = 1, priority =5)
	public void step(){
		time = RepastEssentials.GetTickCount();
		clock.convertTicks(time);
		/*
		if (time==480.0){
			System.out.println(time%240.0+"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
		}
		*/
		if(clock.getDay()%5==0 && clock.getHour()==9 && clock.getMin()==0){
			for(SME s: customers){				
				Stock stock=s.getStock();
				double regularStock=s.getRegularStockLevel();
				stock.setStockLevel(stock.getStockLevel()+regularStock);
				stock.setStockUnitsAboveGround(stock.getStockUnitsAboveGround()+regularStock*(1.0-stock.getRatioLocation()));
				stock.setStockUnitsGround(stock.getStockUnitsGround()+regularStock*stock.getRatioLocation());
			
			}
		}
		
	}
	public void supply(){
		
	}
	public void cancelSupply(){
		
	}
	public String getID() {
		return ID;
	}
	public void setID(String iD) {
		ID = iD;
	}
	public double getAmountSupply() {
		return amount;
	}
	public void setAmountSupply(double amount) {
		this.amount = amount;
	}
	public int getFrequency() {
		return frequency;
	}
	public void setFrequency(int frequency) {
		this.frequency = frequency;
	}
	public int getPriority() {
		return priority;
	}
	public void setPriority(int priority) {
		this.priority = priority;
	}

}
